package com.ssy.lingxi.common.constant.settle;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 会员收据发票订单类型
 * @author 伍将
 * @date 2020/10/28
 * @version 2.0.0
 */
public enum ReceiptInvoiceOrderTypeEnum {

    /**
     * 所有
     */
    ALL(0, "所有"),
    /**
     * 询价采购
     */
    INQUIRY_TO_PURCHASE(1, "询价采购"),
    /**
     * 需求采购
     */
    NEED_TO_PURCHASE(2, "需求采购"),
    /**
     * 现货采购
     */
    SPOT_PURCHASING(3, "现货采购"),
    /**
     * 集采
     */
    COLLECTIVE_PURCHASE(4, "集采"),
    /**
     * 渠道直采
     */
    CHANNEL_STRAIGHT_MINING(5, "渠道直采"),
    /**
     * 渠道现货
     */
    CHANNEL_SPOT(6, "渠道现货"),
    /**
     * 积分兑换
     */
    CREDITS_EXCHANGE(7, "积分兑换"),
    /**
     * 渠道积分兑换
     */
    CHANNEL_POINT_EXCHANGE(8, "渠道积分兑换"),
    /**
     * 其他
     */
    OTHER(999, "");

    private final Integer code;
    private final String message;

    ReceiptInvoiceOrderTypeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public static String getMessage(Integer code) {
        return Arrays.stream(ReceiptInvoiceOrderTypeEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL).getMessage();
    }
}
